import pkg from "./package.json";
import typescript from "rollup-plugin-typescript";
import sourceMaps from "rollup-plugin-sourcemaps";
import resolve from "@rollup/plugin-node-resolve";
import commonjs from "@rollup/plugin-commonjs";
import replace from "@rollup/plugin-replace";
import {uglify} from "rollup-plugin-uglify";
// import livereload from "rollup-plugin-livereload";
// import serve from 'rollup-plugin-serve';
import requireContext from "rollup-plugin-require-context"
export default {
  input: "./src/index.ts",
  plugins: [
    requireContext({include:['**/*.js','**/*.ts']}),
    replace({
      "process.env.NODE_ENV": JSON.stringify("development"),
      "process.env.VUE_ENV": JSON.stringify("browser"),
      "process.env.LANGUAGE": JSON.stringify(process.env.LANGUAGE),
      "preventAssignment": true
    }),
    resolve(),
    commonjs(),
    typescript({
      exclude: "node_modules/**",
      typescript: require("typescript"),
    }),
    sourceMaps(),
    uglify(),
    // livereload(),
    // serve({
    //   open: true, // 自动打开页面
    //   port: 8000,
    //   openPage: './index_rollup.html', // 打开的页面
    //   contentBase: ''
    // })
  ],
  output: [
    {
      format: "umd",
      file: pkg.main,
      sourcemap: true,
      name: 'localHttp'
    }
  ],
};
